#ifndef __CONTROL_H
#define __CONTROL_H

#include "filter.h"

extern unsigned char g_ucMainEventCount;
extern float  g_fAccAngle;
extern float g_fGyroAngleSpeed;
extern float g_fCarAngle;
extern unsigned int g_nLeftMotorPulse;
extern int g_nSpeedTarget;
extern int g_nLeftMotorOutput;
extern float g_fCarSpeed,g_fCarSpeedPrev;
extern int nPwmBais,nPwm;


void GetMpuData(void);
void AngleCalculate(void);
void GetMotorPulse(void);
int SpeedInnerControl(int nPulse,int nTarget);
void SetMotorVoltAndDre(int nMotorPwm);
//extern unsigned char g_ucMainEventCount;
//extern float g_fAccAngle;//加速度传感器经过atan2()解算得到的角度
//extern float g_fGyroAngleSpeed;//陀螺仪角速度
//extern float g_fCarAngle;//小车倾角
//extern unsigned int g_nLeftMotorPulse;
//extern int g_nSpeedTarget;
//extern int g_nLeftMotorOutput;
//extern float g_fCarSpeed,g_fCarSpeedPrev;
//extern int nPwmBais,nPwm;//PWM增量，PWM总量

//void GetMpuData(void);
//void AngleCalculate(void);
//void GetMotorPulse(void);
//int SpeedInnerControl(int nPulse,int nTarget);
//void SetMotorVoltageAndDirection(int nMotorPwm);

//extern unsigned int g_nMainEventCount;//主事件计数，用在中断中
//extern unsigned int g_nGetPulseCount;//捕获脉冲计数，用在中断中
//extern float g_fCarAngle;
//extern unsigned int g_nLeftMotorPulse;
//extern int g_nSpeedTarget;
//extern int g_nLeftMotorOutput;

//void GetMpuData(void);
//void AngleCalculate(void);
//void GetMotorPulse(void);
//void SetMotorVoltageAndDirection(int nLeftMotorPwm,int nRightMotorPwm);
//void MotorOutput(void);
//void AngleControl(void);

#endif


